package net.qhzw.admin.controller;

import net.qhzw.admin.entity.SysPermission;
import net.qhzw.admin.service.SysPermissionService;
import net.qhzw.common.model.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/***
 * 权限菜单前端控制器
 */

@RestController
@RequestMapping("sys/permission")
public class SysPermissionController {


    @Autowired
    private SysPermissionService permissionService;


    /***
     * 根据权限id获取菜单权限信息
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public JsonResult getPermission(@PathVariable(value = "id") String id){
        return permissionService.getPermission(id);
    }


    /***
     * 查询全部菜单权限信息
     * @return
     */
    @GetMapping
    public JsonResult getPermissionAll(){
        return permissionService.getPermissionAll();
    }

    /***
     * 添加菜单权限信息
     * @param permission
     * @return
     */
    @PostMapping
    public JsonResult addPermission(@RequestBody SysPermission permission){
        return permissionService.edit(permission);
    }

    /***
     * 修改菜单权限信息
     * @param permission
     * @return
     */
    @PutMapping
    public JsonResult updatePermission(@RequestBody SysPermission permission){
        return permissionService.edit(permission);
    }


    /***
     * 根据id删除菜单权限信息
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public JsonResult deletePermission(@PathVariable(value = "id") String id){
        return permissionService.deletePermission(id);
    }

}
